<template>
	<view class="member-center">
		<view class="bg"></view>
		<image class="front-image" :src="`${staticUrl}member_priviledge/bg.png?n=`+now" mode="widthFix"></image>
		<view class="header">
			<view class="info">
				<view class="left">
					<x-image :defaultImage="require('@/static/avatar.png')" :src="userInfo.avatarUrl"
						class="x-image"></x-image>
					<view class="aux">
						<view class="name-and-level-img">

							<view class="name" v-if="userInfo && userInfo.nickName && userInfo.nickName.length>0">
								{{userInfo.nickName}}
							</view>
							<view class="name" v-else>微信用户</view>

							<u-icon name="integral-fill" color="#FFFF00" size="20"></u-icon>
						</view>
						<view class="validate-desc" :src="userInfo.avatarUrl">永久有效</view>
					</view>
				</view>
				<view class="right">
					<view class="member-rule" @click="onGotoMemberRule">会员规则</view>
					<u-icon name="arrow-right" size="12"></u-icon>
				</view>
			</view>
		</view>

		<view class="layout">
			<image class="card" :src="`${staticUrl}member_priviledge/vip.png?n=`+now" mode="widthFix"></image>

			<image class="priviledge" :src="`${staticUrl}member_priviledge/priviledge.png?n=`+now" mode="widthFix">
			</image>

			<!-- 成长任务 -->
			<view class="task" :style="{'padding-bottom': device.bottomHeight+'px'}">
				<view class="task-header" v-if="taskList.length>0">
					<view class="title">成长任务</view>
					<u-icon name="arrow-right" size="20"></u-icon>
				</view>
				<view v-for="(item, index) in taskList" class="task-item">
					<view class="left">
						<x-image class="x-image" :src="item.url"></x-image>
						<view class="task-info">
							<view class="name">{{item.name}}</view>
							<view class="desc">每完成1笔订单，获得1点成长值</view>
						</view>
					</view>
					<view class="right">{{item.desc==='待开发' ? '敬请期待' : '去wan'}}</view>
				</view>
			</view>
		</view>

		<view class="seperate-line"></view>

	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import XNavigationBar from '@/components/navigationBar/xNavigationBar.vue'
	import XImage from '@/components/image/xImage.vue'

	import {
		ThemeMixin
	} from '@/mixins/theme/xThemeMixin.js'
	export default {
		mixins: [ThemeMixin],
		components: {
			XNavigationBar,
			XImage
		},
		computed: {
			...mapState(['userInfo', 'device'])
		},
		data() {
			return {
				now: Date.now(),
				staticUrl: this.$Config.staticUrl,
				taskList: [{
						url: require('@/static/member/order.png'),
						name: '完成下单',
						desc: '待开发', //'每完成1笔订单，获得1点成长值',
					},
					{
						url: require('@/static/member/shopping.png'),
						name: '购买商品',
						desc: '待开发', // 每消费1元获得1点成长值',
					},
					{
						url: require('@/static/member/sign.png'),
						name: '每日签到',
						desc: '待开发',
						// desc: '完成后可获得1点成长值，除此外连续签到还可以获得积分、有会员',
					},
				],
			}
		},

		methods: {
			onGotoMemberRule() {
				uni.navigateTo({
					// /pages/protocol/protocol?id=INTEGRAL_RULE&title=积分规则
					url: '/pages/protocol/protocol?id=MEMBER_PROTOCOL&title=会员权益说明'
				})
			}
		}

	}
</script>

<!-- 头部个人信息 -->
<style lang="scss" scoped>
	@import "@/mixins/theme/xTheme.scss";

	.member-center {
		// background-color: #000;
		width: 100%;
		height: 100%;

		.bg {
			background-color: #000;
			width: 100%;
			z-index: -2;
		}

		.front-image {
			width: 100%;
			z-index: -1;
			position: absolute;
		}

		.header {
			width: 100%;
			height: 320rpx;
			// background: $x-theme-card-background;
			display: flex;
			flex-direction: column;

			.info {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 40rpx;

				.left {
					display: flex;

					.x-image {
						margin-left: 32rpx;
						width: 120rpx;
						height: 120rpx;
						border-radius: 60rpx;
						overflow: hidden;
					}

					.aux {
						margin-left: 16rpx;
						display: flex;
						flex-direction: column;
						justify-content: center;

						.name-and-level-img {
							display: flex;

							.name {
								font-size: 32rpx;
								font-family: PingFang-SC-Bold, PingFang-SC;
								font-weight: 500;
								color: #FFF;
							}

							.level-img {
								margin-left: 8rpx;
								width: 32rpx;
								height: 32rpx;
							}
						}

						.validate-desc {
							margin-top: 10rpx;
							font-size: 28rpx;
							font-family: PingFang-SC;
							font-weight: 500;
							color: #A5A5A5;
						}
					}
				}

				.right {
					display: flex;
					margin-right: 16rpx;

					.member-rule {
						font-size: 32rpx;
						font-family: PingFang-SC;
						font-weight: 500;
						color: #A5A5A5;
						margin-right: 8rpx;
					}
				}
			}
		}

		.layout {
			position: relative;
			top: -150rpx;

			.card {
				position: relative;
				// top: -100rpx;
				order-radius: 16rpx;
				width: 100%;
			}

			.priviledge {
				width: 100%;
			}

			.task {
				width: 100%;
				background-color: white;

				.task-header {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					height: 160rpx;
					align-items: center;
					padding: 0rpx 20rpx;

					.title {
						font-size: 36rpx;
						font-family: PingFang-SC-Bold;
						font-weight: 600;
						color: #2D2D2D;
					}
				}

				.task-item {
					margin: 0rpx 32rpx 20rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.left {
						display: flex;
						align-items: center;

						.x-image {
							width: 80rpx;
							height: 80rpx;
							border-radius: 40rpx;
							overflow: hidden;
						}

						.task-info {
							margin-left: 16rpx;
							display: flex;
							flex-direction: column;
							justify-content: center;

							.name {
								font-size: 32rpx;
								font-family: PingFang-SC-Bold, PingFang-SC;
								font-weight: 600;
								color: #2D2D2D;
								margin-left: 8rpx;
							}

							.desc {
								margin-left: 8rpx;
								margin-top: 10rpx;
								font-size: 28rpx;
								font-family: PingFang-SC;
								font-weight: 500;
								color: #A5A5A5;
							}

						}
					}

					.right {
						font-size: 32rpx;
						font-family: PingFang-SC-Bold;
						font-weight: 600;
						/* margin-right: 32rpx; */
						padding: 4rpx 20rpx;
						background-color: #DBB568;
						color: white;
						height: 60rpx;
						border-radius: 30rpx;
						line-height: 52rpx;
					}
				}
			}


		}

	}
</style>

<!-- 任务 -->
<style lang="scss" socped>
	.seperate-line {
		height: 20rpx;
		width: 100%;
		background: #F9F9F9;
	}
</style>